package homework.api04;

import java.util.Arrays;

public class MyArrayList<T> {
    private Object[] data;
    private int size =10;
    private int len=0;
    MyArrayList(){
        data = new Object[size];
    }
    public Boolean add(T t){
        if (len==size){
            data = Arrays.copyOf(data,size+=5);
        }
        data[len++] = t;
        return true;
    }
    public Object get(int index){
        return data[index];
    }
    public Object set(int index,T t){
        Object oldValue = data[index];
        data[index] = t;
        return oldValue;
    }
    public String toString() {
        return Arrays.toString(Arrays.copyOf(data,len));
    }

}
